package org.budo.filestore.buffer;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.budo.filestore.wrapper.FileStoreWrapper;

import lombok.Getter;
import lombok.Setter;

/**
 * 基类
 * 
 * @author lmw
 */
@Getter
@Setter
public class AbstractBufferFileStore extends FileStoreWrapper {
    private static final int THREAD_COUNT = 5;

    private Map<String, byte[]> bufferMap = new ConcurrentHashMap<String, byte[]>();

    private ExecutorService executorService;

    public ExecutorService executorService() {
        if (null != this.executorService) {
            return this.executorService;
        }

        synchronized (AbstractBufferFileStore.class) {
            if (null != this.executorService) {
                return this.executorService;
            }

            return this.executorService = Executors.newFixedThreadPool(THREAD_COUNT);
        }
    }
}